package com.anlogic.sdk.openocd.model;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;

public class JtagCable {
	public static final String VID = "0x0403";
	public static final String PID = "0x6042";
	
	public static final String NAME_PROPERTY = "Name";

	public static final String IDCODE_PROPERTY = "ID Code";

	public static final String IRLENGTH_PROPERTY = "IR Length";

	public static final String ISFPGA_PROPERTY = "FPGA?";

	public static final String FREQUENCE_PROPERTY = "Frequency";

	public static final String[] AUTO_DETECTED_PROPERTIES = new String[] { NAME_PROPERTY, IDCODE_PROPERTY,
			IRLENGTH_PROPERTY, ISFPGA_PROPERTY, FREQUENCE_PROPERTY };

	public static final String[] MANUAL_CONFIG_PROPERTIES = new String[] { NAME_PROPERTY, IDCODE_PROPERTY,
			IRLENGTH_PROPERTY, ISFPGA_PROPERTY };
	
	private String name;
	
	private String frequency;
	
	private String usbPort;
	
	private List<JtagDevice> devices = new ArrayList<JtagDevice>();

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getFrequency() {
		return this.frequency;
	}

	public void setFrequency(String frequency) {
		this.frequency = frequency;
	}
	
	public String getUsbPort() {
		return this.usbPort;
	}

	public void setUsbPort(String usbPort) {
		this.usbPort = usbPort;
	}
	
	public List<JtagDevice> getDevice() {
		return this.devices;
	}
	
	public void addDevice(JtagDevice device) {
		this.devices.add(device);
	}
	
	public String toJsonString() {
		Gson gson = new Gson();
		return gson.toJson(this);
	}
	
	public static JtagCable readJsonString(String json) {
		Gson gson = new Gson();
		return gson.fromJson(json, JtagCable.class);
	}
}
